package bairui.international.config;

import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.IHookCallBack;
import org.testng.IHookable;
import org.testng.ITestContext;
import org.testng.ITestResult;
import org.testng.TestListenerAdapter;
import org.testng.annotations.Listeners;

import com.sh_lianjing.sound.beep.BeepLocal;

import bairui.international.config.Config_Beep.BeepListener;

@Listeners({ BeepListener.class })
public class Config_Beep extends AbstractTestNGSpringContextTests {
//	AbstractTransactionalTestNGSpringContextTests
	/**
	 * 测试发出声响监听器
	 */
	static public class BeepListener extends TestListenerAdapter implements IHookable {
		@Override
		public void onTestFailure(ITestResult tr) {
			BeepLocal.fail();
		}
		
		@Override
		public void run(IHookCallBack callBack, ITestResult testResult) {
			try{
				callBack.runTestMethod(testResult);
			} catch (Exception e) {
				BeepLocal.fail();
				throw e;
			}
		}
		
		@Override
		public void onFinish(ITestContext testContext) {
			BeepLocal.success();
		}
	}
	
}
